<template>
  <div class="media-upload-view">
    <!-- 页面头部 -->
    <div class="page-header glass-card">
      <div class="header-content">
        <div class="header-main">
          <div class="header-info">
            <h1 class="page-title">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" stroke="currentColor" stroke-width="2"/>
              </svg>
              媒体上传
            </h1>
            <p class="page-description">上传照片、视频等媒体文件，支持批量上传和智能分类</p>
          </div>

          <div class="header-actions">
            <button class="action-btn secondary" @click="openSettings">
              <svg fill="none" viewBox="0 0 24 24">
                <circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2"/>
                <path d="M12 1v6m0 6v6m11-7h-6m-6 0H1" stroke="currentColor" stroke-width="2"/>
              </svg>
              上传设置
            </button>

            <button :disabled="isUploading" class="action-btn primary" @click="selectFiles">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="2"/>
                <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2"/>
                <line stroke="currentColor" stroke-width="2" x1="16" x2="8" y1="13" y2="13"/>
              </svg>
              选择文件
            </button>
          </div>
        </div>

        <!-- 上传统计 -->
        <div class="upload-stats">
          <div class="stat-item">
            <div class="stat-value">{{ uploadStats.total }}</div>
            <div class="stat-label">总文件数</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">{{ uploadStats.completed }}</div>
            <div class="stat-label">已完成</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">{{ uploadStats.failed }}</div>
            <div class="stat-label">失败</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">{{ formatFileSize(uploadStats.totalSize) }}</div>
            <div class="stat-label">总大小</div>
          </div>
        </div>
      </div>
    </div>

    <div class="main-content">
      <!-- 拖拽上传区域 -->
      <div
        :class="{
          'is-dragover': isDragover,
          'is-uploading': isUploading,
          'has-files': files.length > 0
        }"
        class="upload-dropzone"
        @click="selectFiles"
        @dragover.prevent="handleDragover"
        @dragleave.prevent="handleDragleave"
        @drop.prevent="handleDrop"
      >
        <div class="dropzone-content">
          <div v-if="files.length === 0" class="dropzone-empty">
            <div class="dropzone-icon">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" stroke="currentColor" stroke-width="2"/>
                <polyline points="7,10 12,15 17,10" stroke="currentColor" stroke-width="2"/>
                <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="15" y2="3"/>
              </svg>
            </div>
            <h3 class="dropzone-title">拖拽文件到此处或点击选择</h3>
            <p class="dropzone-description">
              支持 JPG、PNG、GIF、MP4、MOV 等格式<br>
              单个文件最大 {{ formatFileSize(maxFileSize) }}，最多可选择 {{ maxFiles }} 个文件
            </p>
            <div class="dropzone-features">
              <div class="feature-item">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span>智能压缩</span>
              </div>
              <div class="feature-item">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M9 12l2 2 4-4" stroke="currentColor" stroke-width="2"/>
                  <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span>格式检查</span>
              </div>
              <div class="feature-item">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span>安全上传</span>
              </div>
            </div>
          </div>

          <!-- 文件列表 -->
          <div v-else class="files-container">
            <div class="files-header">
              <h3 class="files-title">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="2"/>
                </svg>
                已选择 {{ files.length }} 个文件
              </h3>

              <div class="files-actions">
                <button :disabled="isUploading" class="files-action-btn" @click="clearFiles">
                  <svg fill="none" viewBox="0 0 24 24">
                    <polyline points="3,6 5,6 21,6" stroke="currentColor" stroke-width="2"/>
                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" stroke="currentColor" stroke-width="2"/>
                  </svg>
                  清空
                </button>

                <button :disabled="isUploading" class="files-action-btn" @click="selectFiles">
                  <svg fill="none" viewBox="0 0 24 24">
                    <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                    <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="8" y2="16"/>
                    <line stroke="currentColor" stroke-width="2" x1="8" x2="16" y1="12" y2="12"/>
                  </svg>
                  添加更多
                </button>
              </div>
            </div>

            <!-- 文件网格 -->
            <div class="files-grid">
              <div
                v-for="(file, index) in files"
                :key="file.id"
                :class="file.status"
                class="file-item"
              >
                <!-- 文件预览 -->
                <div class="file-preview">
                  <img v-if="file.preview" :alt="file.name" :src="file.preview" />
                  <div v-else class="file-icon">
                    <svg v-if="file.type.startsWith('video')" fill="none" viewBox="0 0 24 24">
                      <polygon points="23 7 16 12 23 17 23 7" stroke="currentColor" stroke-width="2"/>
                      <rect height="14" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="15" x="1" y="5"/>
                    </svg>
                    <svg v-else fill="none" viewBox="0 0 24 24">
                      <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="2"/>
                    </svg>
                  </div>

                  <!-- 状态覆盖层 -->
                  <div class="file-overlay">
                    <!-- 上传中 -->
                    <div v-if="file.status === 'uploading'" class="upload-progress">
                      <div class="progress-circle">
                        <div class="progress-text">{{ file.progress }}%</div>
                      </div>
                    </div>

                    <!-- 已完成 -->
                    <div v-else-if="file.status === 'completed'" class="upload-success">
                      <svg fill="none" viewBox="0 0 24 24">
                        <path d="M9 12l2 2 4-4" stroke="currentColor" stroke-width="3"/>
                        <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                      </svg>
                    </div>

                    <!-- 失败 -->
                    <div v-else-if="file.status === 'error'" class="upload-error">
                      <svg fill="none" viewBox="0 0 24 24">
                        <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                        <line stroke="currentColor" stroke-width="2" x1="15" x2="9" y1="9" y2="15"/>
                        <line stroke="currentColor" stroke-width="2" x1="9" x2="15" y1="9" y2="15"/>
                      </svg>
                    </div>

                    <!-- 删除按钮 -->
                    <button
                      v-if="!isUploading || file.status === 'error'"
                      class="file-remove"
                      @click.stop="removeFile(index)"
                    >
                      <svg fill="none" viewBox="0 0 24 24">
                        <line stroke="currentColor" stroke-width="2" x1="18" x2="6" y1="6" y2="18"/>
                        <line stroke="currentColor" stroke-width="2" x1="6" x2="18" y1="6" y2="18"/>
                      </svg>
                    </button>
                  </div>

                  <!-- 进度条 -->
                  <div v-if="file.status === 'uploading'" class="file-progress-bar">
                    <div :style="{ width: file.progress + '%' }" class="progress-fill"></div>
                  </div>
                </div>

                <!-- 文件信息 -->
                <div class="file-info">
                  <div :title="file.name" class="file-name">{{ file.name }}</div>
                  <div class="file-meta">
                    <span class="file-size">{{ formatFileSize(file.size) }}</span>
                    <span v-if="file.status === 'error'" class="file-error">{{ file.error }}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

    <!-- 上传配置 -->
    <div v-if="files.length > 0" class="upload-config glass-card">
      <div class="config-container">
        <div class="config-header">
          <h3 class="config-title">
            <svg fill="none" viewBox="0 0 24 24">
              <circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2"/>
              <path d="M12 1v6m0 6v6m11-7h-6m-6 0H1" stroke="currentColor" stroke-width="2"/>
            </svg>
            上传设置
          </h3>
          <span class="config-subtitle">配置文件存储和处理选项</span>
        </div>

        <!-- 存储设置 -->
        <div class="config-section">
          <h4 class="section-title">
            <svg fill="none" viewBox="0 0 24 24">
              <path d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2V7" stroke="currentColor" stroke-width="2"/>
              <path d="M8 21l8-8-8-8" stroke="currentColor" stroke-width="2"/>
            </svg>
            存储配置
          </h4>

          <div class="config-grid">
            <div class="config-item">
              <label class="config-label">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" stroke="currentColor" stroke-width="2"/>
                </svg>
                存储相册
              </label>
              <div class="select-wrapper">
                <select v-model="uploadOptions.albumId" class="config-select">
                  <option value="">选择相册</option>
                  <option value="family">家庭生活</option>
                  <option value="travel">旅行足迹</option>
                  <option value="celebration">庆祝时刻</option>
                  <option value="daily">日常记录</option>
                </select>
                <button class="create-album-btn" @click="showCreateAlbum = true">
                  <svg fill="none" viewBox="0 0 24 24">
                    <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="5" y2="19"/>
                    <line stroke="currentColor" stroke-width="2" x1="5" x2="19" y1="12" y2="12"/>
                  </svg>
                  新建相册
                </button>
              </div>
            </div>

            <div class="config-item">
              <label class="config-label">
                <svg fill="none" viewBox="0 0 24 24">
                  <rect height="11" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="18" x="3" y="11"/>
                  <circle cx="12" cy="16" r="1" stroke="currentColor" stroke-width="2"/>
                  <path d="M7 11V7a5 5 0 0110 0v4" stroke="currentColor" stroke-width="2"/>
                </svg>
                隐私设置
              </label>
              <div class="radio-group">
                <label class="radio-item">
                  <input v-model="uploadOptions.privacy" type="radio" value="private" />
                  <div class="radio-circle"></div>
                  <div class="radio-content">
                    <span class="radio-title">私有</span>
                    <span class="radio-desc">仅自己可见</span>
                  </div>
                </label>
                <label class="radio-item">
                  <input v-model="uploadOptions.privacy" type="radio" value="family" />
                  <div class="radio-circle"></div>
                  <div class="radio-content">
                    <span class="radio-title">家庭可见</span>
                    <span class="radio-desc">家庭成员可查看</span>
                  </div>
                </label>
                <label class="radio-item">
                  <input v-model="uploadOptions.privacy" type="radio" value="public" />
                  <div class="radio-circle"></div>
                  <div class="radio-content">
                    <span class="radio-title">公开</span>
                    <span class="radio-desc">所有人可见</span>
                  </div>
                </label>
              </div>
            </div>
          </div>
        </div>

        <!-- 处理设置 -->
        <div class="config-section">
          <h4 class="section-title">
            <svg fill="none" viewBox="0 0 24 24">
              <circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2"/>
              <path d="M12 1v6m0 6v6" stroke="currentColor" stroke-width="2"/>
            </svg>
            处理选项
          </h4>

          <div class="config-row">
            <div class="config-item">
              <label class="config-label">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z" stroke="currentColor" stroke-width="2"/>
                  <line stroke="currentColor" stroke-width="2" x1="7" x2="7.01" y1="7" y2="7"/>
                </svg>
                文件标签
              </label>
              <div class="tags-input-wrapper">
                <input
                  v-model="tagInput"
                  class="tags-input"
                  placeholder="输入标签后按回车添加"
                  type="text"
                  @keydown.enter="addTag"
                />
                <div v-if="uploadOptions.tags.length > 0" class="tags-display">
                  <span v-for="tag in uploadOptions.tags" :key="tag" class="tag-item">
                    {{ tag }}
                    <button class="tag-remove" @click="removeTag(tag)">
                      <svg fill="none" viewBox="0 0 24 24">
                        <line stroke="currentColor" stroke-width="2" x1="18" x2="6" y1="6" y2="18"/>
                        <line stroke="currentColor" stroke-width="2" x1="6" x2="18" y1="6" y2="18"/>
                      </svg>
                    </button>
                  </span>
                </div>
              </div>
            </div>

            <div class="config-item">
              <label class="config-label">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M16 4h2a2 2 0 012 2v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2h2" stroke="currentColor" stroke-width="2"/>
                  <rect height="4" rx="1" ry="1" stroke="currentColor" stroke-width="2" width="8" x="8" y="2"/>
                </svg>
                重复处理
              </label>
              <select v-model="uploadOptions.duplicateHandling" class="config-select">
                <option value="rename">自动重命名</option>
                <option value="skip">跳过重复文件</option>
                <option value="replace">覆盖原文件</option>
              </select>
            </div>
          </div>
        </div>

        <!-- 功能选项 -->
        <div class="config-section">
          <h4 class="section-title">
            <svg fill="none" viewBox="0 0 24 24">
              <path d="M9 12l2 2 4-4" stroke="currentColor" stroke-width="2"/>
              <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
            </svg>
            功能选项
          </h4>

          <div class="feature-options">
            <label class="feature-item">
              <input v-model="uploadOptions.generateThumbnail" class="feature-checkbox" type="checkbox" />
              <div class="feature-box">
                <div class="feature-check">
                  <svg fill="none" viewBox="0 0 24 24">
                    <polyline points="20,6 9,17 4,12" stroke="currentColor" stroke-width="2"/>
                  </svg>
                </div>
              </div>
              <div class="feature-content">
                <span class="feature-title">自动生成缩略图</span>
                <span class="feature-desc">为图片和视频生成预览缩略图</span>
              </div>
            </label>

            <label class="feature-item">
              <input v-model="uploadOptions.enableAiTags" class="feature-checkbox" type="checkbox" />
              <div class="feature-box">
                <div class="feature-check">
                  <svg fill="none" viewBox="0 0 24 24">
                    <polyline points="20,6 9,17 4,12" stroke="currentColor" stroke-width="2"/>
                  </svg>
                </div>
              </div>
              <div class="feature-content">
                <span class="feature-title">AI智能标签</span>
                <span class="feature-desc">使用AI自动识别并添加内容标签</span>
              </div>
            </label>

            <label class="feature-item">
              <input v-model="uploadOptions.extractMetadata" class="feature-checkbox" type="checkbox" />
              <div class="feature-box">
                <div class="feature-check">
                  <svg fill="none" viewBox="0 0 24 24">
                    <polyline points="20,6 9,17 4,12" stroke="currentColor" stroke-width="2"/>
                  </svg>
                </div>
              </div>
              <div class="feature-content">
                <span class="feature-title">提取元数据</span>
                <span class="feature-desc">保存拍摄时间、位置、设备等信息</span>
              </div>
            </label>

            <label class="feature-item">
              <input v-model="uploadOptions.enableGpsInfo" class="feature-checkbox" type="checkbox" />
              <div class="feature-box">
                <div class="feature-check">
                  <svg fill="none" viewBox="0 0 24 24">
                    <polyline points="20,6 9,17 4,12" stroke="currentColor" stroke-width="2"/>
                  </svg>
                </div>
              </div>
              <div class="feature-content">
                <span class="feature-title">位置信息</span>
                <span class="feature-desc">保存和显示文件的地理位置信息</span>
              </div>
            </label>
          </div>
        </div>
      </div>
    </div>

    <!-- 文件列表 -->
    <div v-if="fileList.length > 0" class="file-list-section">
      <div class="list-header">
        <div class="list-title-section">
          <div class="batch-select">
            <label class="checkbox-item">
              <input
                v-model="selectAll"
                class="checkbox-input"
                type="checkbox"
                @change="handleSelectAll"
              />
              <div class="checkbox-box"></div>
            </label>
          </div>
          <h3 class="list-title">
            文件列表
            <span class="file-count">({{ fileList.length }}个文件{{ selectedFiles.length > 0 ? `，已选${selectedFiles.length}个` : '' }})</span>
          </h3>
        </div>

        <div class="list-actions">
          <button
            v-if="selectedFiles.length > 0"
            class="list-btn danger"
            @click="removeSelectedFiles"
          >
            <svg fill="none" viewBox="0 0 24 24">
              <polyline points="3,6 5,6 21,6" stroke="currentColor" stroke-width="2"/>
              <path d="M19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2" stroke="currentColor" stroke-width="2"/>
            </svg>
            删除选中 ({{ selectedFiles.length }})
          </button>

          <button class="list-btn secondary" @click="clearAll">
            <svg fill="none" viewBox="0 0 24 24">
              <polyline points="3,6 5,6 21,6" stroke="currentColor" stroke-width="2"/>
              <path d="M19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2" stroke="currentColor" stroke-width="2"/>
            </svg>
            清空全部
          </button>

          <button
            v-if="isUploading"
            class="list-btn secondary"
            @click="pauseUpload"
          >
            <svg fill="none" viewBox="0 0 24 24">
              <rect height="16" stroke="currentColor" stroke-width="2" width="4" x="6" y="4"/>
              <rect height="16" stroke="currentColor" stroke-width="2" width="4" x="14" y="4"/>
            </svg>
            暂停上传
          </button>

          <button
            :disabled="isUploading || fileList.length === 0"
            class="list-btn primary"
            @click="startUpload"
          >
            <div v-if="isUploading" class="loading-spinner"></div>
            <svg v-else fill="none" viewBox="0 0 24 24">
              <path d="M7 10l5-5 5 5M12 5v12" stroke="currentColor" stroke-width="2"/>
            </svg>
            {{ isUploading ? `上传中 (${completedCount}/${fileList.length})` : '开始上传' }}
          </button>
        </div>
      </div>

      <div class="file-list">
        <div
          v-for="(fileItem, index) in fileList"
          :key="index"
          :class="[
            'file-item',
            {
              'uploading': fileItem.uploading,
              'completed': fileItem.completed,
              'error': fileItem.error,
              'selected': selectedFiles.includes(index)
            }
          ]"
        >
          <!-- 文件选择 -->
          <div class="file-select">
            <label class="checkbox-item">
              <input
                v-model="selectedFiles"
                :disabled="fileItem.uploading"
                :value="index"
                class="checkbox-input"
                type="checkbox"
              />
              <div class="checkbox-box"></div>
            </label>
          </div>

          <!-- 文件预览 -->
          <div class="file-preview">
            <img
              v-if="fileItem.preview"
              :alt="fileItem.name"
              :src="fileItem.preview"
              class="preview-image"
            />
            <div v-else :class="fileItem.type" class="file-icon">
              <svg v-if="fileItem.type === 'image'" fill="none" viewBox="0 0 24 24">
                <rect height="18" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="18" x="3" y="3"/>
                <circle cx="8.5" cy="8.5" r="1.5" stroke="currentColor" stroke-width="2"/>
                <polyline points="21,15 16,10 5,21" stroke="currentColor" stroke-width="2"/>
              </svg>
              <svg v-else-if="fileItem.type === 'video'" fill="none" viewBox="0 0 24 24">
                <polygon fill="currentColor" points="23,7 16,12 23,17"/>
                <rect fill="none" height="14" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="15" x="1" y="5"/>
              </svg>
              <svg v-else-if="fileItem.type === 'audio'" fill="none" viewBox="0 0 24 24">
                <path d="M9 18V5l12-2v13" stroke="currentColor" stroke-width="2"/>
                <circle cx="6" cy="18" r="3" stroke="currentColor" stroke-width="2"/>
                <circle cx="18" cy="16" r="3" stroke="currentColor" stroke-width="2"/>
              </svg>
              <svg v-else fill="none" viewBox="0 0 24 24">
                <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2"/>
                <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2"/>
              </svg>
            </div>
          </div>

          <!-- 文件信息 -->
          <div class="file-info">
            <div class="file-name">{{ fileItem.name }}</div>
            <div class="file-meta">
              <span class="file-size">{{ formatFileSize(fileItem.size) }}</span>
              <span class="file-type">{{ fileItem.extension.toUpperCase() }}</span>
              <span v-if="fileItem.dimensions" class="file-dimensions">
                {{ fileItem.dimensions }}
              </span>
            </div>

            <!-- 上传进度 -->
            <div v-if="fileItem.uploading || fileItem.completed || fileItem.error" class="upload-status">
              <div v-if="fileItem.uploading" class="progress-bar">
                <div :style="{ width: fileItem.progress + '%' }" class="progress-fill"></div>
                <span class="progress-text">{{ fileItem.progress }}%</span>
              </div>

              <div v-else-if="fileItem.completed" class="status-success">
                <svg fill="none" viewBox="0 0 24 24">
                  <polyline points="20,6 9,17 4,12" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span>上传完成</span>
              </div>

              <div v-else-if="fileItem.error" class="status-error">
                <svg fill="none" viewBox="0 0 24 24">
                  <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                  <line stroke="currentColor" stroke-width="2" x1="15" x2="9" y1="9" y2="15"/>
                  <line stroke="currentColor" stroke-width="2" x1="9" x2="15" y1="9" y2="15"/>
                </svg>
                <span>{{ fileItem.errorMsg || '上传失败' }}</span>
              </div>
            </div>
          </div>

          <!-- 操作按钮 -->
          <div class="file-actions">
            <button
              v-if="fileItem.error"
              class="file-action-btn retry"
              @click="retryUpload(index)"
            >
              <svg fill="none" viewBox="0 0 24 24">
                <polyline points="23,4 23,10 17,10" stroke="currentColor" stroke-width="2"/>
                <path d="M20.49,15a9,9,0,1,1-2.12-9.36L23,10" stroke="currentColor" stroke-width="2"/>
              </svg>
            </button>

            <button
              v-if="!fileItem.uploading && !fileItem.completed"
              class="file-action-btn remove"
              @click="removeFile(index)"
            >
              <svg fill="none" viewBox="0 0 24 24">
                <line stroke="currentColor" stroke-width="2" x1="18" x2="6" y1="6" y2="18"/>
                <line stroke="currentColor" stroke-width="2" x1="6" x2="18" y1="6" y2="18"/>
              </svg>
            </button>
          </div>
        </div>
      </div>

      <!-- 上传进度总览 -->
      <div class="upload-summary">
        <div class="summary-stats">
          <div class="summary-item">
            <span class="summary-label">总进度</span>
            <div class="summary-progress">
              <div class="summary-progress-bar">
                <div
                  :style="{ width: overallProgress + '%' }"
                  class="summary-progress-fill"
                ></div>
              </div>
              <span class="summary-progress-text">{{ overallProgress }}%</span>
            </div>
          </div>

          <div class="summary-item">
            <span class="summary-label">完成</span>
            <span class="summary-value success">{{ completedCount }}</span>
          </div>

          <div class="summary-item">
            <span class="summary-label">失败</span>
            <span class="summary-value error">{{ errorCount }}</span>
          </div>

          <div class="summary-item">
            <span class="summary-label">剩余</span>
            <span class="summary-value">{{ fileList.length - completedCount - errorCount }}</span>
          </div>
        </div>
      </div>
      </div>

      <!-- 最近上传 -->
    <div class="recent-section">
      <div class="recent-header">
        <h3 class="recent-title">最近上传</h3>
        <router-link class="view-all" to="/media">
          查看全部
          <svg fill="currentColor" viewBox="0 0 16 16">
            <path d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
          </svg>
        </router-link>
      </div>

      <div v-if="recentUploads.length > 0" class="recent-grid">
        <div
          v-for="item in recentUploads"
          :key="item.id"
          class="recent-item"
        >
          <div class="recent-thumbnail">
            <img
              v-if="item.thumbnailUrl"
              :alt="item.name"
              :src="item.thumbnailUrl"
            />
            <div v-else :class="item.fileType" class="recent-icon">
              <svg v-if="item.fileType === 'image'" fill="none" viewBox="0 0 24 24">
                <rect height="18" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="18" x="3" y="3"/>
                <circle cx="8.5" cy="8.5" r="1.5" stroke="currentColor" stroke-width="2"/>
                <polyline points="21,15 16,10 5,21" stroke="currentColor" stroke-width="2"/>
              </svg>
              <svg v-else-if="item.fileType === 'video'" fill="none" viewBox="0 0 24 24">
                <polygon fill="currentColor" points="23,7 16,12 23,17"/>
                <rect fill="none" height="14" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="15" x="1" y="5"/>
              </svg>
              <svg v-else fill="none" viewBox="0 0 24 24">
                <path d="M9 18V5l12-2v13" stroke="currentColor" stroke-width="2"/>
                <circle cx="6" cy="18" r="3" stroke="currentColor" stroke-width="2"/>
                <circle cx="18" cy="16" r="3" stroke="currentColor" stroke-width="2"/>
              </svg>
            </div>
          </div>
          <div class="recent-info">
            <h4 class="recent-name">{{ item.name }}</h4>
            <p class="recent-meta">
              {{ formatDate(item.uploadedAt) }} • {{ formatFileSize(item.size) }}
            </p>
          </div>
        </div>
      </div>

      <div v-else class="recent-empty">
        <div class="empty-icon">
          <svg fill="none" viewBox="0 0 24 24">
            <rect height="18" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="18" x="3" y="3"/>
            <circle cx="8.5" cy="8.5" r="1.5" stroke="currentColor" stroke-width="2"/>
            <polyline points="21,15 16,10 5,21" stroke="currentColor" stroke-width="2"/>
          </svg>
        </div>
        <p class="empty-text">暂无上传记录</p>
      </div>
    </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { Notify } from '@opentiny/vue'

const router = useRouter()

interface FileItem {
  file: File
  name: string
  size: number
  type: string
  extension: string
  preview?: string
  dimensions?: string
  uploading: boolean
  completed: boolean
  error: boolean
  errorMsg?: string
  progress: number
}

// 响应式数据
const isDragover = ref(false)
const isUploading = ref(false)
const fileInputRef = ref<HTMLInputElement>()
const files = ref<FileItem[]>([])
const fileList = ref<FileItem[]>([])
const recentUploads = ref<any[]>([])
const selectedFiles = ref<number[]>([])
const selectAll = ref(false)
const tagInput = ref('')
const showCreateAlbum = ref(false)

// 上传配置
const uploadOptions = ref({
  albumId: '',
  privacy: 'family',
  tags: [] as string[],
  duplicateHandling: 'rename',
  generateThumbnail: true,
  enableAiTags: true,
  extractMetadata: true,
  enableGpsInfo: true
})

// 计算属性
const uploadStats = computed(() => ({
  total: fileList.value.length,
  completed: fileList.value.filter(file => file.completed).length,
  failed: fileList.value.filter(file => file.error).length,
  totalSize: fileList.value.reduce((total, file) => total + file.size, 0)
}))

const totalSize = computed(() => {
  return fileList.value.reduce((total, file) => total + file.size, 0)
})

const completedCount = computed(() => {
  return fileList.value.filter(file => file.completed).length
})

const errorCount = computed(() => {
  return fileList.value.filter(file => file.error).length
})

const overallProgress = computed(() => {
  if (fileList.value.length === 0) return 0
  const totalProgress = fileList.value.reduce((sum, file) => {
    if (file.completed) return sum + 100
    if (file.error) return sum + 0
    return sum + file.progress
  }, 0)
  return Math.round(totalProgress / fileList.value.length)
})

// 拖拽处理
const handleDragover = (e: DragEvent) => {
  e.preventDefault()
  isDragover.value = true
}

const handleDragleave = () => {
  isDragover.value = false
}

const handleDrop = (e: DragEvent) => {
  e.preventDefault()
  isDragover.value = false

  const files = Array.from(e.dataTransfer?.files || [])
  handleFiles(files)
}

// 文件选择
const selectFiles = () => {
  fileInputRef.value?.click()
}

const selectFolder = () => {
  const input = document.createElement('input')
  input.type = 'file'
  input.webkitdirectory = true
  input.multiple = true
  input.onchange = (e: any) => {
    const files = Array.from(e.target.files || [])
    handleFiles(files)
  }
  input.click()
}

const handleFileSelect = (e: Event) => {
  const input = e.target as HTMLInputElement
  const files = Array.from(input.files || [])
  handleFiles(files)
  // 清空input以允许重复选择相同文件
  input.value = ''
}

const pasteFromClipboard = async () => {
  try {
    const clipboardItems = await navigator.clipboard.read()
    const files: File[] = []

    for (const clipboardItem of clipboardItems) {
      for (const type of clipboardItem.types) {
        if (type.startsWith('image/')) {
          const blob = await clipboardItem.getType(type)
          const file = new File([blob], `clipboard-${Date.now()}.${type.split('/')[1]}`, { type })
          files.push(file)
        }
      }
    }

    if (files.length > 0) {
      handleFiles(files)
      Notify({
        type: 'success',
        message: `从剪贴板添加了 ${files.length} 个文件`,
        position: 'top-right'
      })
    } else {
      Notify({
        type: 'warning',
        message: '剪贴板中没有找到图片文件',
        position: 'top-right'
      })
    }
  } catch (error) {
    Notify({
      type: 'error',
      message: '访问剪贴板失败，请检查浏览器权限',
      position: 'top-right'
    })
  }
}

// 文件处理
const handleFiles = (files: File[]) => {
  const validFiles = files.filter(file => {
    // 文件验证
    const validation = validateFile(file)
    if (!validation.valid) {
      Notify({
        type: 'warning',
        message: `文件 ${file.name}：${validation.error}`,
        position: 'top-right'
      })
      return false
    }

    // 重复文件检查
    if (fileList.value.some(item => item.name === file.name && item.size === file.size)) {
      Notify({
        type: 'warning',
        message: `文件 ${file.name} 已存在，已跳过`,
        position: 'top-right'
      })
      return false
    }

    return true
  })

  validFiles.forEach(file => {
    const fileItem: FileItem = {
      file,
      name: file.name,
      size: file.size,
      type: getFileType(file.type),
      extension: getFileExtension(file.name),
      uploading: false,
      completed: false,
      error: false,
      progress: 0
    }

    // 生成预览
    if (fileItem.type === 'image') {
      generateImagePreview(fileItem)
    }

    fileList.value.push(fileItem)
  })

  if (validFiles.length > 0) {
    Notify({
      type: 'success',
      message: `成功添加 ${validFiles.length} 个文件`,
      position: 'top-right'
    })
  }
}

const generateImagePreview = (fileItem: FileItem) => {
  const reader = new FileReader()
  reader.onload = (e) => {
    fileItem.preview = e.target?.result as string

    // 获取图片尺寸
    const img = new Image()
    img.onload = () => {
      fileItem.dimensions = `${img.width} × ${img.height}`
    }
    img.src = fileItem.preview
  }
  reader.readAsDataURL(fileItem.file)
}

// 上传相关
const startUpload = async () => {
  if (isUploading.value || fileList.value.length === 0) return

  isUploading.value = true

  const pendingFiles = fileList.value.filter(file => !file.completed && !file.uploading)

  for (const fileItem of pendingFiles) {
    if (!isUploading.value) break // 支持中途停止

    try {
      await uploadSingleFile(fileItem)
    } catch (error) {
      console.error('Upload error:', error)
    }

    // 添加小延迟避免过快的请求
    await new Promise(resolve => setTimeout(resolve, 100))
  }

  isUploading.value = false

  // 刷新最近上传
  loadRecentUploads()

  const successCount = fileList.value.filter(f => f.completed).length
  const failCount = fileList.value.filter(f => f.error).length

  if (failCount === 0) {
    Notify({
      type: 'success',
      message: `全部 ${successCount} 个文件上传成功！`,
      position: 'top-right'
    })
  } else {
    Notify({
      type: 'warning',
      message: `${successCount} 个成功，${failCount} 个失败`,
      position: 'top-right'
    })
  }
}

const uploadSingleFile = async (fileItem: FileItem): Promise<void> => {
  return new Promise((resolve, reject) => {
    fileItem.uploading = true
    fileItem.error = false
    fileItem.progress = 0

    // 模拟上传过程
    const simulateUpload = () => {
      const interval = setInterval(() => {
        fileItem.progress += Math.random() * 15

        if (fileItem.progress >= 100) {
          clearInterval(interval)
          fileItem.progress = 100
          fileItem.uploading = false

          // 90% 成功率
          if (Math.random() > 0.1) {
            fileItem.completed = true
            resolve()
          } else {
            fileItem.error = true
            fileItem.errorMsg = '网络错误，上传失败'
            reject(new Error('Upload failed'))
          }
        }
      }, 200)
    }

    simulateUpload()
  })
}

const retryUpload = async (index: number) => {
  const fileItem = fileList.value[index]
  try {
    await uploadSingleFile(fileItem)
  } catch (error) {
    console.error('Retry upload failed:', error)
  }
}

const removeFile = (index: number) => {
  fileList.value.splice(index, 1)
}

const pauseUpload = () => {
  isUploading.value = false
  Notify({
    type: 'info',
    message: '上传已暂停',
    position: 'top-right'
  })
}

const clearAll = () => {
  if (isUploading.value) {
    Notify({
      type: 'warning',
      message: '上传进行中，无法清空列表',
      position: 'top-right'
    })
    return
  }
  fileList.value = []
  selectedFiles.value = []
  selectAll.value = false
}

// 批量选择功能
const handleSelectAll = () => {
  if (selectAll.value) {
    selectedFiles.value = fileList.value.map((_, index) => index).filter(index =>
      !fileList.value[index].uploading
    )
  } else {
    selectedFiles.value = []
  }
}

const removeSelectedFiles = () => {
  if (selectedFiles.value.length === 0) return

  // 按索引从大到小排序，避免删除时索引变化的问题
  const sortedIndices = [...selectedFiles.value].sort((a, b) => b - a)

  sortedIndices.forEach(index => {
    if (!fileList.value[index].uploading) {
      fileList.value.splice(index, 1)
    }
  })

  selectedFiles.value = []
  selectAll.value = false

  Notify({
    type: 'success',
    message: `已删除 ${sortedIndices.length} 个文件`,
    position: 'top-right'
  })
}

// 文件类型和大小限制配置
const FILE_TYPE_LIMITS = {
  image: {
    extensions: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'tiff'],
    maxSize: 50 * 1024 * 1024, // 50MB
    label: '图片'
  },
  video: {
    extensions: ['mp4', 'avi', 'mov', 'wmv', 'flv', '3gp', 'mkv', 'webm'],
    maxSize: 2 * 1024 * 1024 * 1024, // 2GB
    label: '视频'
  },
  audio: {
    extensions: ['mp3', 'wav', 'flac', 'aac', 'ogg', 'm4a', 'wma'],
    maxSize: 100 * 1024 * 1024, // 100MB
    label: '音频'
  },
  document: {
    extensions: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'rtf'],
    maxSize: 100 * 1024 * 1024, // 100MB
    label: '文档'
  }
}

// 工具函数
const getFileType = (mimeType: string): string => {
  if (mimeType.startsWith('image/')) return 'image'
  if (mimeType.startsWith('video/')) return 'video'
  if (mimeType.startsWith('audio/')) return 'audio'
  return 'document'
}

const getFileExtension = (fileName: string): string => {
  return fileName.split('.').pop()?.toLowerCase() || ''
}

const validateFile = (file: File): { valid: boolean; error?: string } => {
  const extension = getFileExtension(file.name)
  const fileType = getFileType(file.type)
  const typeConfig = FILE_TYPE_LIMITS[fileType]

  // 检查文件扩展名
  if (!typeConfig.extensions.includes(extension)) {
    return {
      valid: false,
      error: `不支持的${typeConfig.label}格式 (.${extension})，支持的格式：${typeConfig.extensions.join(', ')}`
    }
  }

  // 检查文件大小
  if (file.size > typeConfig.maxSize) {
    return {
      valid: false,
      error: `${typeConfig.label}文件过大 (${formatFileSize(file.size)})，最大支持 ${formatFileSize(typeConfig.maxSize)}`
    }
  }

  // 检查文件名长度
  if (file.name.length > 255) {
    return {
      valid: false,
      error: '文件名过长，最多支持255个字符'
    }
  }

  return { valid: true }
}

const formatFileSize = (bytes: number): string => {
  if (bytes === 0) return '0 B'
  const k = 1024
  const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
  const i = Math.floor(Math.log(bytes) / Math.log(k))
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
}

const formatDate = (dateStr: string | Date): string => {
  const date = new Date(dateStr)
  const now = new Date()
  const diff = now.getTime() - date.getTime()
  const days = Math.floor(diff / (1000 * 60 * 60 * 24))

  if (days === 0) return '今天'
  if (days === 1) return '昨天'
  if (days < 7) return `${days} 天前`

  return date.toLocaleDateString('zh-CN')
}

// 数据加载
const loadRecentUploads = async () => {
  try {
    // 模拟加载最近上传
    await new Promise(resolve => setTimeout(resolve, 500))

    recentUploads.value = [
      {
        id: 1,
        name: '家庭合影.jpg',
        fileType: 'image',
        size: 2048000,
        uploadedAt: new Date('2024-01-20T10:30:00'),
        thumbnailUrl: 'https://via.placeholder.com/120x120/3b82f6/ffffff?text=Family'
      },
      {
        id: 2,
        name: '生日视频.mp4',
        fileType: 'video',
        size: 15728640,
        uploadedAt: new Date('2024-01-19T15:45:00')
      },
      {
        id: 3,
        name: '音乐收藏.mp3',
        fileType: 'audio',
        size: 4194304,
        uploadedAt: new Date('2024-01-18T20:15:00')
      }
    ]
  } catch (error) {
    console.error('Load recent uploads failed:', error)
  }
}

// 标签管理
const addTag = () => {
  const tag = tagInput.value.trim()
  if (tag && !uploadOptions.value.tags.includes(tag)) {
    uploadOptions.value.tags.push(tag)
    tagInput.value = ''
  }
}

const removeTag = (tag: string) => {
  const index = uploadOptions.value.tags.indexOf(tag)
  if (index > -1) {
    uploadOptions.value.tags.splice(index, 1)
  }
}

// 设置相关
const openSettings = () => {
  console.log('打开上传设置')
  // 这里可以实现设置面板的打开逻辑
}

// 初始化
onMounted(() => {
  loadRecentUploads()
})
</script>

<style lang="scss" scoped>
@import '@/assets/styles/glassmorphism.scss';

.media-upload-view {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 2rem 1rem;

  .glass-card {
    @include glass-card;
    margin-bottom: 2rem;
  }

  .page-header {
    .header-content {
      display: flex;
      flex-direction: column;
      gap: 2rem;

      .header-main {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 2rem;

        .header-info {
          .page-title {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            font-size: 2.25rem;
            font-weight: 700;
            color: white;
            margin: 0 0 0.5rem 0;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

            svg {
              width: 32px;
              height: 32px;
              color: rgba(255, 255, 255, 0.8);
            }
          }

          .page-description {
            color: rgba(255, 255, 255, 0.8);
            font-size: 1.1rem;
            margin: 0;
            line-height: 1.5;
          }
        }

        .header-actions {
          display: flex;
          gap: 1rem;
          flex-shrink: 0;

          .action-btn {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            color: white;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
            cursor: pointer;

            &:hover {
              background: rgba(255, 255, 255, 0.2);
              transform: translateY(-2px);
              box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
            }

            &:disabled {
              opacity: 0.6;
              cursor: not-allowed;
              transform: none;
            }

            svg {
              width: 18px;
              height: 18px;
            }

            &.primary {
              background: rgba(59, 130, 246, 0.3);
              border-color: rgba(59, 130, 246, 0.4);

              &:hover {
                background: rgba(59, 130, 246, 0.4);
              }
            }

            &.secondary {
              background: rgba(16, 185, 129, 0.3);
              border-color: rgba(16, 185, 129, 0.4);

              &:hover {
                background: rgba(16, 185, 129, 0.4);
              }
            }
          }
        }
      }

      .upload-stats {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;

        .stat-item {
          text-align: center;
          padding: 1rem;
          background: rgba(255, 255, 255, 0.1);
          backdrop-filter: blur(5px);
          border-radius: 12px;
          border: 1px solid rgba(255, 255, 255, 0.1);

          .stat-value {
            display: block;
            font-size: 1.75rem;
            font-weight: 700;
            color: white;
            margin-bottom: 0.25rem;
          }

          .stat-label {
            color: rgba(255, 255, 255, 0.8);
            font-size: 0.9rem;
            font-weight: 500;
          }
        }
      }
    }
  }

  .main-content {
    max-width: 1200px;
    margin: 0 auto;

    .upload-dropzone {
      @include glass-card;
      padding: 3rem 2rem;
      text-align: center;
      cursor: pointer;
      transition: all 0.3s ease;
      border: 2px dashed rgba(255, 255, 255, 0.3);
      margin-bottom: 2rem;
      position: relative;
      overflow: hidden;

      &::before {
        content: '';
        position: absolute;
        inset: -2px;
        background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        border-radius: 16px;
        padding: 2px;
        mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        mask-composite: exclude;
        opacity: 0;
        transition: opacity 0.3s ease;
      }

      &:hover, &.is-dragover {
        transform: scale(1.02);
        border-color: rgba(59, 130, 246, 0.6);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);

        &::before {
          opacity: 1;
        }
      }

      &.is-uploading {
        border-color: rgba(16, 185, 129, 0.6);

        .dropzone-content .dropzone-title {
          color: rgba(16, 185, 129, 0.9);
        }
      }

      &.has-files {
        border-style: solid;
        border-color: rgba(59, 130, 246, 0.4);
      }

      .dropzone-content {
        .dropzone-empty {
          .dropzone-icon {
            width: 80px;
            height: 80px;
            margin: 0 auto 1.5rem;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            animation: float 3s ease-in-out infinite;

            svg {
              width: 40px;
              height: 40px;
              color: rgba(255, 255, 255, 0.8);
            }
          }

          .dropzone-title {
            font-size: 1.5rem;
            font-weight: 600;
            color: white;
            margin: 0 0 0.75rem 0;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
          }

          .dropzone-description {
            color: rgba(255, 255, 255, 0.8);
            line-height: 1.6;
            margin: 0 0 2rem 0;
            font-size: 1.1rem;
          }

          .dropzone-features {
            display: flex;
            justify-content: center;
            gap: 2rem;
            flex-wrap: wrap;

            .feature-item {
              display: flex;
              align-items: center;
              gap: 0.5rem;
              color: rgba(255, 255, 255, 0.9);
              font-weight: 500;

              svg {
                width: 20px;
                height: 20px;
                color: rgba(59, 130, 246, 0.8);
              }
            }
          }
        }

        .files-container {
          .files-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);

            .files-title {
              display: flex;
              align-items: center;
              gap: 0.75rem;
              color: white;
              font-size: 1.25rem;
              font-weight: 600;
              margin: 0;

              svg {
                width: 24px;
                height: 24px;
                color: rgba(255, 255, 255, 0.8);
              }
            }

            .files-actions {
              display: flex;
              gap: 0.75rem;

              .files-action-btn {
                display: flex;
                align-items: center;
                gap: 0.5rem;
                padding: 0.5rem 1rem;
                background: rgba(255, 255, 255, 0.1);
                backdrop-filter: blur(5px);
                border: 1px solid rgba(255, 255, 255, 0.2);
                border-radius: 8px;
                color: white;
                cursor: pointer;
                font-size: 0.9rem;
                transition: all 0.2s ease;

                &:hover:not(:disabled) {
                  background: rgba(255, 255, 255, 0.2);
                  transform: translateY(-1px);
                }

                &:disabled {
                  opacity: 0.5;
                  cursor: not-allowed;
                }

                svg {
                  width: 16px;
                  height: 16px;
                }
              }
            }
          }

          .files-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 1rem;

            .file-item {
              background: rgba(255, 255, 255, 0.1);
              backdrop-filter: blur(10px);
              border: 1px solid rgba(255, 255, 255, 0.1);
              border-radius: 12px;
              overflow: hidden;
              transition: all 0.3s ease;
              position: relative;

              &:hover {
                transform: translateY(-4px);
                box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
              }

              &.pending {
                border-color: rgba(107, 114, 128, 0.4);
              }

              &.uploading {
                border-color: rgba(59, 130, 246, 0.6);
                box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
              }

              &.completed {
                border-color: rgba(16, 185, 129, 0.6);
                box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
              }

              &.error {
                border-color: rgba(239, 68, 68, 0.6);
                box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
              }

              .file-preview {
                position: relative;
                aspect-ratio: 1;
                overflow: hidden;

                img {
                  width: 100%;
                  height: 100%;
                  object-fit: cover;
                }

                .file-icon {
                  width: 100%;
                  height: 100%;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  background: rgba(255, 255, 255, 0.05);

                  svg {
                    width: 48px;
                    height: 48px;
                    color: rgba(255, 255, 255, 0.6);
                  }
                }

                .file-overlay {
                  position: absolute;
                  inset: 0;
                  background: rgba(0, 0, 0, 0.6);
                  display: flex;
                  align-items: center;
                  justify-content: center;

                  .upload-progress .progress-circle {
                    width: 60px;
                    height: 60px;
                    border-radius: 50%;
                    background: rgba(255, 255, 255, 0.1);
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    border: 3px solid rgba(59, 130, 246, 0.3);
                    border-top-color: #3b82f6;
                    animation: spin 1s linear infinite;

                    .progress-text {
                      color: white;
                      font-weight: 600;
                      font-size: 0.9rem;
                    }
                  }

                  .upload-success svg, .upload-error svg {
                    width: 32px;
                    height: 32px;
                    color: white;
                  }

                  .file-remove {
                    position: absolute;
                    top: 8px;
                    right: 8px;
                    width: 28px;
                    height: 28px;
                    background: rgba(239, 68, 68, 0.8);
                    border: none;
                    border-radius: 50%;
                    color: white;
                    cursor: pointer;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    transition: all 0.2s ease;

                    &:hover {
                      background: rgba(220, 38, 38, 0.9);
                      transform: scale(1.1);
                    }

                    svg {
                      width: 14px;
                      height: 14px;
                    }
                  }
                }

                .file-progress-bar {
                  position: absolute;
                  bottom: 0;
                  left: 0;
                  right: 0;
                  height: 4px;
                  background: rgba(255, 255, 255, 0.2);

                  .progress-fill {
                    height: 100%;
                    background: linear-gradient(90deg, #3b82f6, #06b6d4);
                    transition: width 0.3s ease;
                  }
                }
              }

              .file-info {
                padding: 1rem;

                .file-name {
                  color: white;
                  font-weight: 500;
                  font-size: 0.9rem;
                  margin-bottom: 0.5rem;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                }

                .file-meta {
                  display: flex;
                  gap: 0.75rem;
                  font-size: 0.8rem;
                  color: rgba(255, 255, 255, 0.7);

                  .file-size, .file-error {
                    white-space: nowrap;
                  }

                  .file-error {
                    color: rgba(239, 68, 68, 0.9);
                  }
                }
              }
            }
          }
        }
      }
    }

    .upload-config {
      .config-container {
        .config-header {
          text-align: center;
          margin-bottom: 2rem;
          padding-bottom: 1.5rem;
          border-bottom: 1px solid rgba(255, 255, 255, 0.1);

          .config-title {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.75rem;
            font-size: 1.5rem;
            font-weight: 600;
            color: white;
            margin: 0 0 0.5rem 0;

            svg {
              width: 24px;
              height: 24px;
              color: rgba(255, 255, 255, 0.8);
            }
          }

          .config-subtitle {
            color: rgba(255, 255, 255, 0.7);
            font-size: 1rem;
          }
        }

        .config-section {
          margin-bottom: 2rem;

          .section-title {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 1.1rem;
            font-weight: 600;
            color: white;
            margin: 0 0 1.5rem 0;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);

            svg {
              width: 20px;
              height: 20px;
              color: rgba(255, 255, 255, 0.8);
            }
          }

          .config-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 1.5rem;
          }

          .config-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1.5rem;
          }

          .config-item {
            .config-label {
              display: flex;
              align-items: center;
              gap: 0.5rem;
              font-size: 0.95rem;
              font-weight: 500;
              color: rgba(255, 255, 255, 0.9);
              margin-bottom: 0.75rem;

              svg {
                width: 16px;
                height: 16px;
                color: rgba(255, 255, 255, 0.7);
              }
            }

            .select-wrapper {
              display: flex;
              gap: 0.75rem;
              align-items: stretch;

              .config-select {
                flex: 1;
              }

              .create-album-btn {
                display: flex;
                align-items: center;
                gap: 0.5rem;
                padding: 0.75rem 1rem;
                background: rgba(59, 130, 246, 0.2);
                border: 1px solid rgba(59, 130, 246, 0.3);
                border-radius: 8px;
                color: rgba(59, 130, 246, 0.9);
                font-size: 0.85rem;
                font-weight: 500;
                cursor: pointer;
                transition: all 0.2s ease;
                white-space: nowrap;

                &:hover {
                  background: rgba(59, 130, 246, 0.3);
                  transform: translateY(-1px);
                }

                svg {
                  width: 14px;
                  height: 14px;
                }
              }
            }

            .config-select {
              width: 100%;
              padding: 0.75rem 1rem;
              background: rgba(255, 255, 255, 0.1);
              backdrop-filter: blur(5px);
              border: 1px solid rgba(255, 255, 255, 0.2);
              border-radius: 8px;
              color: white;
              font-size: 0.9rem;
              outline: none;
              transition: all 0.2s ease;

              &:focus {
                border-color: rgba(59, 130, 246, 0.6);
                box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
              }

              option {
                background: #1f2937;
                color: white;
              }
            }

            .radio-group {
              display: flex;
              flex-direction: column;
              gap: 0.75rem;

              .radio-item {
                display: flex;
                align-items: center;
                gap: 0.75rem;
                padding: 0.75rem;
                background: rgba(255, 255, 255, 0.05);
                border: 1px solid rgba(255, 255, 255, 0.1);
                border-radius: 8px;
                cursor: pointer;
                transition: all 0.2s ease;

                &:hover {
                  background: rgba(255, 255, 255, 0.1);
                  border-color: rgba(255, 255, 255, 0.2);
                }

                input[type="radio"] {
                  display: none;
                }

                .radio-circle {
                  width: 18px;
                  height: 18px;
                  border: 2px solid rgba(255, 255, 255, 0.4);
                  border-radius: 50%;
                  position: relative;
                  flex-shrink: 0;
                  transition: all 0.2s ease;

                  &::after {
                    content: '';
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    width: 8px;
                    height: 8px;
                    background: #3b82f6;
                    border-radius: 50%;
                    transform: translate(-50%, -50%) scale(0);
                    transition: transform 0.2s ease;
                  }
                }

                input:checked + .radio-circle {
                  border-color: #3b82f6;

                  &::after {
                    transform: translate(-50%, -50%) scale(1);
                  }
                }

                .radio-content {
                  display: flex;
                  flex-direction: column;
                  gap: 0.25rem;

                  .radio-title {
                    color: white;
                    font-weight: 500;
                    font-size: 0.9rem;
                  }

                  .radio-desc {
                    color: rgba(255, 255, 255, 0.7);
                    font-size: 0.8rem;
                  }
                }
              }
            }

            .tags-input-wrapper {
              .tags-input {
                width: 100%;
                padding: 0.75rem 1rem;
                background: rgba(255, 255, 255, 0.1);
                backdrop-filter: blur(5px);
                border: 1px solid rgba(255, 255, 255, 0.2);
                border-radius: 8px;
                color: white;
                font-size: 0.9rem;
                outline: none;
                transition: all 0.2s ease;
                margin-bottom: 0.75rem;

                &:focus {
                  border-color: rgba(59, 130, 246, 0.6);
                  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
                }

                &::placeholder {
                  color: rgba(255, 255, 255, 0.5);
                }
              }

              .tags-display {
                display: flex;
                flex-wrap: wrap;
                gap: 0.5rem;

                .tag-item {
                  display: flex;
                  align-items: center;
                  gap: 0.5rem;
                  padding: 0.375rem 0.75rem;
                  background: rgba(59, 130, 246, 0.2);
                  border: 1px solid rgba(59, 130, 246, 0.3);
                  border-radius: 16px;
                  color: rgba(59, 130, 246, 0.9);
                  font-size: 0.8rem;
                  font-weight: 500;

                  .tag-remove {
                    width: 16px;
                    height: 16px;
                    background: none;
                    border: none;
                    border-radius: 50%;
                    color: rgba(59, 130, 246, 0.7);
                    cursor: pointer;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    transition: all 0.2s ease;

                    &:hover {
                      background: rgba(59, 130, 246, 0.1);
                      color: rgba(59, 130, 246, 0.9);
                    }

                    svg {
                      width: 12px;
                      height: 12px;
                    }
                  }
                }
              }
            }
          }

          .feature-options {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 1rem;

            .feature-item {
              display: flex;
              align-items: flex-start;
              gap: 0.75rem;
              padding: 1rem;
              background: rgba(255, 255, 255, 0.05);
              border: 1px solid rgba(255, 255, 255, 0.1);
              border-radius: 12px;
              cursor: pointer;
              transition: all 0.2s ease;

              &:hover {
                background: rgba(255, 255, 255, 0.1);
                border-color: rgba(255, 255, 255, 0.2);
                transform: translateY(-1px);
              }

              .feature-checkbox {
                display: none;
              }

              .feature-box {
                width: 20px;
                height: 20px;
                border: 2px solid rgba(255, 255, 255, 0.3);
                border-radius: 4px;
                position: relative;
                flex-shrink: 0;
                margin-top: 2px;
                transition: all 0.2s ease;

                .feature-check {
                  position: absolute;
                  inset: 0;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  opacity: 0;
                  transform: scale(0.5);
                  transition: all 0.2s ease;

                  svg {
                    width: 14px;
                    height: 14px;
                    color: white;
                  }
                }
              }

              input:checked + .feature-box {
                background: #3b82f6;
                border-color: #3b82f6;

                .feature-check {
                  opacity: 1;
                  transform: scale(1);
                }
              }

              .feature-content {
                display: flex;
                flex-direction: column;
                gap: 0.375rem;

                .feature-title {
                  color: white;
                  font-weight: 500;
                  font-size: 0.95rem;
                }

                .feature-desc {
                  color: rgba(255, 255, 255, 0.7);
                  font-size: 0.85rem;
                  line-height: 1.4;
                }
              }
            }
          }
        }
      }
    }
  }

  // 动画效果
  @keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
  }

  @keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  // 响应式设计
  @media (max-width: 768px) {
    .media-upload-view {
      padding: 1rem 0.5rem;

      .page-header .header-content {
        .header-main {
          flex-direction: column;
          align-items: center;
          text-align: center;
          gap: 1.5rem;

          .header-actions {
            justify-content: center;
            flex-wrap: wrap;
          }
        }

        .upload-stats {
          grid-template-columns: repeat(2, 1fr);
        }
      }

      .main-content .upload-dropzone {
        padding: 2rem 1rem;

        .dropzone-content .dropzone-empty {
          .dropzone-features {
            flex-direction: column;
            gap: 1rem;
          }
        }

        .files-container .files-grid {
          grid-template-columns: 1fr;
        }
      }

      .upload-config .config-container .config-section {
        .config-grid, .config-row {
          grid-template-columns: 1fr;
        }

        .feature-options {
          grid-template-columns: 1fr;
        }
      }
    }
  }
}

      &.has-files {
        border-style: solid;
        background: rgba(59, 130, 246, 0.02);
      }

      .drop-content {
        .drop-icon {
          width: 64px;
          height: 64px;
          margin: 0 auto 1rem;
          color: #3b82f6;

          svg {
            width: 100%;
            height: 100%;
          }
        }

        .drop-title {
          font-size: 1.25rem;
          font-weight: 600;
          color: #1e293b;
          margin: 0 0 0.5rem 0;
        }

        .drop-subtitle {
          color: #64748b;
          margin: 0 0 1rem 0;
        }

        .drop-info {
          display: flex;
          justify-content: center;
          align-items: center;
          gap: 0.5rem;
          font-size: 0.85rem;
          color: #9ca3af;

          .info-separator {
            color: #d1d5db;
          }
        }
      }

      .file-input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
      }
    }

    .upload-actions {
      display: flex;
      justify-content: center;
      gap: 1rem;

      .action-btn {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        border-radius: 8px;
        border: none;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;

        svg {
          width: 18px;
          height: 18px;
        }

        &.primary {
          background: #3b82f6;
          color: white;

          &:hover {
            background: #2563eb;
            transform: translateY(-2px);
          }
        }

        &.secondary {
          background: #10b981;
          color: white;

          &:hover {
            background: #059669;
            transform: translateY(-2px);
          }
        }

        &.outline {
          background: transparent;
          border: 1px solid #d1d5db;
          color: #374151;

          &:hover {
            border-color: #9ca3af;
            background: #f9fafb;
          }
        }
      }
    }
  }

  .upload-config {
    max-width: 1200px;
    margin: 0 auto 2rem;

    .config-section {
      background: white;
      padding: 1.5rem;
      border-radius: 12px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

      .config-title {
        font-size: 1.1rem;
        font-weight: 600;
        color: #1e293b;
        margin: 0 0 1.5rem 0;
      }

      .config-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
        margin-bottom: 1.5rem;

        .config-item {
          .config-label {
            display: block;
            font-size: 0.9rem;
            font-weight: 500;
            color: #374151;
            margin-bottom: 0.5rem;
          }

          .config-select,
          .config-input {
            width: 100%;
            padding: 0.5rem 0.75rem;
            border: 1px solid #d1d5db;
            border-radius: 6px;
            font-size: 0.9rem;
            background: white;

            &:focus {
              outline: none;
              border-color: #3b82f6;
              box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
            }
          }
        }
      }

      .config-options {
        display: flex;
        gap: 2rem;
        flex-wrap: wrap;

        .checkbox-item {
          display: flex;
          align-items: center;
          gap: 0.5rem;
          cursor: pointer;

          .checkbox-input {
            display: none;
          }

          .checkbox-box {
            width: 18px;
            height: 18px;
            border: 2px solid #d1d5db;
            border-radius: 4px;
            position: relative;
            transition: all 0.2s ease;

            &::after {
              content: '✓';
              position: absolute;
              inset: 0;
              display: flex;
              align-items: center;
              justify-content: center;
              color: white;
              font-size: 12px;
              font-weight: bold;
              opacity: 0;
              transition: opacity 0.2s ease;
            }
          }

          .checkbox-input:checked + .checkbox-box {
            background: #3b82f6;
            border-color: #3b82f6;

            &::after {
              opacity: 1;
            }
          }

          .checkbox-label {
            font-size: 0.9rem;
            color: #374151;
          }
        }
      }
    }
  }

  .file-list-section {
    max-width: 1200px;
    margin: 0 auto 2rem;

    .list-header {
      background: white;
      padding: 1.5rem;
      border-radius: 12px 12px 0 0;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      display: flex;
      justify-content: space-between;
      align-items: center;

      .list-title-section {
        display: flex;
        align-items: center;
        gap: 1rem;

        .batch-select {
          .checkbox-item {
            display: flex;
            align-items: center;
            cursor: pointer;
          }
        }

        .list-title {
          font-size: 1.1rem;
          font-weight: 600;
          color: #1e293b;
          margin: 0;

          .file-count {
            font-weight: 400;
            color: #6b7280;
          }
        }
      }

      .list-actions {
        display: flex;
        gap: 0.75rem;

        .list-btn {
          display: flex;
          align-items: center;
          gap: 0.5rem;
          padding: 0.5rem 1rem;
          border-radius: 6px;
          border: none;
          font-size: 0.9rem;
          font-weight: 500;
          cursor: pointer;
          transition: all 0.2s ease;

          svg {
            width: 16px;
            height: 16px;
          }

          .loading-spinner {
            width: 16px;
            height: 16px;
            border: 2px solid transparent;
            border-top: 2px solid currentColor;
            border-radius: 50%;
            animation: spin 1s linear infinite;
          }

          &.primary {
            background: #3b82f6;
            color: white;

            &:hover:not(:disabled) {
              background: #2563eb;
            }

            &:disabled {
              opacity: 0.6;
              cursor: not-allowed;
            }
          }

          &.secondary {
            background: #f3f4f6;
            color: #374151;

            &:hover {
              background: #e5e7eb;
            }
          }

          &.danger {
            background: #ef4444;
            color: white;

            &:hover {
              background: #dc2626;
            }
          }
        }
      }
    }

    .file-list {
      background: white;
      border-radius: 0 0 12px 12px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      max-height: 400px;
      overflow-y: auto;

      .file-item {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #f1f5f9;
        transition: background-color 0.2s ease;

        &:hover {
          background: #f8fafc;
        }

        &.selected {
          background: rgba(59, 130, 246, 0.05);
          border-left: 4px solid #3b82f6;
        }

        &.uploading {
          border-left: 4px solid #3b82f6;
          background: rgba(59, 130, 246, 0.02);
        }

        &.completed {
          border-left: 4px solid #10b981;
          background: rgba(16, 185, 129, 0.02);
        }

        &.error {
          border-left: 4px solid #ef4444;
          background: rgba(239, 68, 68, 0.02);
        }

        .file-select {
          display: flex;
          align-items: center;
          justify-content: center;
          flex-shrink: 0;

          .checkbox-item {
            display: flex;
            align-items: center;
            cursor: pointer;
            padding: 0.25rem;
          }
        }

        .file-preview {
          width: 48px;
          height: 48px;
          flex-shrink: 0;
          border-radius: 8px;
          overflow: hidden;

          .preview-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
          }

          .file-icon {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;

            &.image {
              background: rgba(59, 130, 246, 0.1);
              color: #3b82f6;
            }

            &.video {
              background: rgba(239, 68, 68, 0.1);
              color: #ef4444;
            }

            &.audio {
              background: rgba(139, 92, 246, 0.1);
              color: #8b5cf6;
            }

            &.document {
              background: rgba(107, 114, 128, 0.1);
              color: #6b7280;
            }

            svg {
              width: 24px;
              height: 24px;
            }
          }
        }

        .file-info {
          flex: 1;
          min-width: 0;

          .file-name {
            font-weight: 500;
            color: #1e293b;
            margin-bottom: 0.25rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }

          .file-meta {
            display: flex;
            gap: 1rem;
            font-size: 0.8rem;
            color: #6b7280;

            span {
              white-space: nowrap;
            }
          }

          .upload-status {
            margin-top: 0.5rem;

            .progress-bar {
              display: flex;
              align-items: center;
              gap: 0.75rem;

              .progress-fill {
                flex: 1;
                height: 4px;
                background: #e5e7eb;
                border-radius: 2px;
                overflow: hidden;
                position: relative;

                &::after {
                  content: '';
                  position: absolute;
                  top: 0;
                  left: 0;
                  height: 100%;
                  background: #3b82f6;
                  width: inherit;
                  transition: width 0.3s ease;
                }
              }

              .progress-text {
                font-size: 0.8rem;
                font-weight: 500;
                color: #3b82f6;
                min-width: 40px;
              }
            }

            .status-success,
            .status-error {
              display: flex;
              align-items: center;
              gap: 0.5rem;
              font-size: 0.8rem;
              font-weight: 500;

              svg {
                width: 16px;
                height: 16px;
              }
            }

            .status-success {
              color: #10b981;
            }

            .status-error {
              color: #ef4444;
            }
          }
        }

        .file-actions {
          display: flex;
          gap: 0.5rem;

          .file-action-btn {
            width: 32px;
            height: 32px;
            border: none;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;

            svg {
              width: 16px;
              height: 16px;
            }

            &.retry {
              background: rgba(245, 158, 11, 0.1);
              color: #f59e0b;

              &:hover {
                background: rgba(245, 158, 11, 0.2);
              }
            }

            &.remove {
              background: rgba(239, 68, 68, 0.1);
              color: #ef4444;

              &:hover {
                background: rgba(239, 68, 68, 0.2);
              }
            }
          }
        }
      }
    }

    .upload-summary {
      background: white;
      padding: 1rem 1.5rem;
      border-radius: 0 0 12px 12px;
      border-top: 1px solid #e5e7eb;

      .summary-stats {
        display: flex;
        justify-content: space-between;
        align-items: center;

        .summary-item {
          display: flex;
          align-items: center;
          gap: 0.75rem;

          .summary-label {
            font-size: 0.9rem;
            color: #6b7280;
          }

          .summary-progress {
            display: flex;
            align-items: center;
            gap: 0.5rem;

            .summary-progress-bar {
              width: 120px;
              height: 6px;
              background: #e5e7eb;
              border-radius: 3px;
              overflow: hidden;

              .summary-progress-fill {
                height: 100%;
                background: #3b82f6;
                transition: width 0.3s ease;
              }
            }

            .summary-progress-text {
              font-size: 0.8rem;
              font-weight: 500;
              color: #3b82f6;
              min-width: 40px;
            }
          }

          .summary-value {
            font-weight: 600;
            font-size: 1.1rem;

            &.success {
              color: #10b981;
            }

            &.error {
              color: #ef4444;
            }
          }
        }
      }
    }
  }

  .recent-section {
    max-width: 1200px;
    margin: 0 auto;

    .recent-header {
      background: white;
      padding: 1.5rem;
      border-radius: 12px 12px 0 0;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .recent-title {
        font-size: 1.1rem;
        font-weight: 600;
        color: #1e293b;
        margin: 0;
      }

      .view-all {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        color: #3b82f6;
        text-decoration: none;
        font-size: 0.9rem;
        font-weight: 500;
        transition: color 0.2s ease;

        &:hover {
          color: #2563eb;
        }

        svg {
          width: 14px;
          height: 14px;
        }
      }
    }

    .recent-grid {
      background: white;
      padding: 1.5rem;
      border-radius: 0 0 12px 12px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 1rem;

      .recent-item {
        display: flex;
        gap: 0.75rem;
        padding: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        transition: all 0.2s ease;

        &:hover {
          border-color: #3b82f6;
          box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
          transform: translateY(-2px);
        }

        .recent-thumbnail {
          width: 48px;
          height: 48px;
          flex-shrink: 0;
          border-radius: 6px;
          overflow: hidden;

          img {
            width: 100%;
            height: 100%;
            object-fit: cover;
          }

          .recent-icon {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;

            &.image {
              background: rgba(59, 130, 246, 0.1);
              color: #3b82f6;
            }

            &.video {
              background: rgba(239, 68, 68, 0.1);
              color: #ef4444;
            }

            &.audio {
              background: rgba(139, 92, 246, 0.1);
              color: #8b5cf6;
            }

            svg {
              width: 20px;
              height: 20px;
            }
          }
        }

        .recent-info {
          flex: 1;
          min-width: 0;

          .recent-name {
            font-size: 0.9rem;
            font-weight: 500;
            color: #1e293b;
            margin: 0 0 0.25rem 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }

          .recent-meta {
            font-size: 0.8rem;
            color: #6b7280;
            margin: 0;
          }
        }
      }
    }

    .recent-empty {
      background: white;
      padding: 2rem;
      border-radius: 0 0 12px 12px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      text-align: center;

      .empty-icon {
        width: 48px;
        height: 48px;
        margin: 0 auto 1rem;
        color: #d1d5db;

        svg {
          width: 100%;
          height: 100%;
        }
      }

      .empty-text {
        color: #6b7280;
        margin: 0;
      }
    }
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

// 响应式设计
@media (max-width: 1200px) {
  .upload-view {
    .page-header .header-content {
      .header-stats {
        gap: 1.5rem;

        .stat-item {
          .stat-number {
            font-size: 1.25rem;
          }

          .stat-label {
            font-size: 0.85rem;
          }
        }
      }
    }

    .upload-config .config-section .config-grid {
      grid-template-columns: repeat(2, 1fr);
    }

    .recent-section .recent-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
}

@media (max-width: 992px) {
  .upload-view {
    .page-header .header-content {
      flex-direction: column;
      gap: 1.5rem;
      text-align: center;
      padding: 1.75rem;

      .header-text .page-title {
        font-size: 1.75rem;
      }

      .header-stats {
        justify-content: center;
        flex-wrap: wrap;
        gap: 1.25rem;
      }
    }

    .upload-section .upload-actions {
      flex-wrap: wrap;
      gap: 0.75rem;

      .action-btn {
        flex: 1;
        min-width: 140px;
      }
    }

    .upload-config .config-section .config-grid {
      grid-template-columns: 1fr;
    }

    .file-list-section {
      .list-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
      }

      .upload-summary .summary-stats {
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;

        .summary-item {
          flex-direction: column;
          text-align: center;
          gap: 0.5rem;

          .summary-progress .summary-progress-bar {
            width: 100px;
          }
        }
      }
    }
  }
}

@media (max-width: 768px) {
  .upload-view {
    padding: 1rem 0.5rem;

    .page-header .header-content {
      flex-direction: column;
      gap: 1rem;
      text-align: center;
      padding: 1.5rem;

      .header-text .page-title {
        font-size: 1.5rem;
      }

      .header-stats {
        gap: 1rem;

        .stat-item {
          .stat-number {
            font-size: 1.1rem;
          }

          .stat-label {
            font-size: 0.8rem;
          }
        }
      }
    }

    .upload-section {
      .drop-zone {
        padding: 2rem 1rem;

        .drop-content {
          .drop-icon {
            width: 48px;
            height: 48px;
          }

          .drop-title {
            font-size: 1.1rem;
          }

          .drop-info {
            flex-direction: column;
            gap: 0.25rem;
            font-size: 0.8rem;

            .info-separator {
              display: none;
            }
          }
        }
      }

      .upload-actions {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;

        .action-btn {
          width: 100%;
          max-width: 300px;
          justify-content: center;
        }
      }
    }

    .upload-config .config-section {
      padding: 1.25rem;

      .config-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
      }

      .config-options {
        flex-direction: column;
        gap: 1rem;
      }
    }

    .file-list-section {
      .list-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.25rem;

        .list-actions {
          justify-content: center;
          flex-wrap: wrap;
        }
      }

      .file-list .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;

        .file-preview {
          align-self: center;
        }

        .file-info {
          width: 100%;

          .file-name {
            text-align: center;
            white-space: normal;
            margin-bottom: 0.5rem;
          }

          .file-meta {
            justify-content: center;
            flex-wrap: wrap;
          }

          .upload-status {
            margin-top: 0.75rem;

            .progress-bar {
              flex-direction: column;
              gap: 0.5rem;
              text-align: center;

              .progress-text {
                min-width: auto;
              }
            }
          }
        }

        .file-actions {
          align-self: center;
        }
      }

      .upload-summary {
        padding: 1rem;

        .summary-stats {
          flex-direction: column;
          gap: 1rem;
          align-items: center;

          .summary-item {
            width: 100%;
            max-width: 200px;

            .summary-progress {
              justify-content: center;

              .summary-progress-bar {
                width: 80px;
              }
            }
          }
        }
      }
    }

    .recent-section {
      .recent-header {
        padding: 1.25rem;

        .recent-title {
          font-size: 1rem;
        }
      }

      .recent-grid {
        grid-template-columns: 1fr;
        padding: 1.25rem;
        gap: 0.75rem;

        .recent-item {
          padding: 0.75rem;

          .recent-info .recent-name {
            font-size: 0.85rem;
          }
        }
      }

      .recent-empty {
        padding: 1.5rem;

        .empty-icon {
          width: 40px;
          height: 40px;
        }
      }
    }
  }
}

@media (max-width: 480px) {
  .upload-view {
    padding: 0.75rem 0.25rem;

    .page-header .header-content {
      padding: 1.25rem;

      .header-text .page-title {
        font-size: 1.35rem;
      }

      .header-stats {
        gap: 0.75rem;

        .stat-item {
          min-width: 60px;

          .stat-number {
            font-size: 1rem;
          }

          .stat-label {
            font-size: 0.75rem;
          }
        }
      }
    }

    .upload-section {
      .drop-zone {
        padding: 1.5rem 0.75rem;

        .drop-content {
          .drop-icon {
            width: 40px;
            height: 40px;
            margin-bottom: 0.75rem;
          }

          .drop-title {
            font-size: 1rem;
          }

          .drop-subtitle {
            font-size: 0.85rem;
          }
        }
      }

      .upload-actions .action-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;

        svg {
          width: 16px;
          height: 16px;
        }
      }
    }

    .upload-config .config-section {
      padding: 1rem;

      .config-title {
        font-size: 1rem;
        margin-bottom: 1rem;
      }

      .config-grid {
        gap: 0.75rem;

        .config-item {
          .config-label {
            font-size: 0.85rem;
            margin-bottom: 0.4rem;
          }

          .config-select,
          .config-input {
            padding: 0.5rem;
            font-size: 0.85rem;
          }
        }
      }

      .config-options {
        gap: 0.75rem;

        .checkbox-item .checkbox-label {
          font-size: 0.85rem;
        }
      }
    }

    .file-list-section {
      .list-header {
        padding: 1rem;

        .list-title {
          font-size: 1rem;
        }

        .list-actions .list-btn {
          padding: 0.5rem 0.75rem;
          font-size: 0.85rem;

          svg,
          .loading-spinner {
            width: 14px;
            height: 14px;
          }
        }
      }

      .file-list .file-item {
        padding: 0.75rem;

        .file-preview {
          width: 40px;
          height: 40px;

          .file-icon svg {
            width: 20px;
            height: 20px;
          }
        }

        .file-info {
          .file-name {
            font-size: 0.85rem;
          }

          .file-meta {
            font-size: 0.75rem;
            gap: 0.5rem;
          }
        }

        .file-actions .file-action-btn {
          width: 28px;
          height: 28px;

          svg {
            width: 14px;
            height: 14px;
          }
        }
      }
    }

    .recent-section {
      .recent-grid {
        padding: 1rem;

        .recent-item {
          padding: 0.6rem;

          .recent-thumbnail {
            width: 40px;
            height: 40px;

            .recent-icon svg {
              width: 18px;
              height: 18px;
            }
          }

          .recent-info {
            .recent-name {
              font-size: 0.8rem;
            }

            .recent-meta {
              font-size: 0.75rem;
            }
          }
        }
      }
    }
  }
}
</style>
